import React from 'react';
import { View, Text } from 'react-native';
import { createAppContainer } from 'react-navigation';
import { createStackNavigator } from 'react-navigation-stack';
import { GestureHandlerRootView } from 'react-native-gesture-handler';

import Index from './pages/index';
import Details from './pages/details';
import Home from './pages/home';

const App = (props) => {
    const { entry } = props;
    const AppNavigator = createStackNavigator(
        {
            Index: {
                screen: Index,
            },
            Details: {
                screen: Details,
            },
            Home: {
                screen: Home,
            },
        },
        {
            initialRouteName: entry ? entry : 'Index',
            headerMode: 'none',
        }
    );

    const AppContainer = createAppContainer(AppNavigator);

    return (
        <GestureHandlerRootView style={{ flex: 1 }}>
            {entry == 'Index' ? <Index {...props} /> : <AppContainer />}
        </GestureHandlerRootView>
    );
};

export default App;
